package com.gomyb.storage;

import com.gomyb.storage.model.CloudStorageAuth;
import com.gomyb.storage.model.StorageSource;
import com.gomyb.storage.model.SingleData;
import lombok.extern.log4j.Log4j2;

import java.io.InputStream;

/**
 * @author <a href="mailto:hellohesir@gmail.com">Mr_He</a>
 * 2019/3/6 19:20
 */
@Log4j2
public abstract class AbstractCloudServiceImpl implements CloudService {

    @Override
    public boolean upload(InputStream inputStream) {
        CloudStorageAuth cloudStorageAuth = SingleData.getSingleData().getCloudStorageAuth();
        StorageSource source = cloudStorageAuth.getSource();
        try {
            return source.upload(cloudStorageAuth,inputStream, getFileName(inputStream), getPath(inputStream));
        } catch (Exception e) {
            log.error(e);
        }
        return false;
    }
}